#include <vector>
#include <iostream>

using namespace std;

int N, K;
const int dir[4][2] = {-1, 0, 1, 0, 0, 1, 0, -1};

int dfs(vector<vector<char> > &plate, vector<int> &cols, int i, int cnt)
{
    if (i == N && cnt != 0)
        return 0;
    if (cnt == 0)
        return 1;
    int sum = 0;
    for (int j = 0; j < N; j++)
        if (!cols[j] && plate[i][j] == '#')
        {
            cols[j] = 1;
            sum += dfs(plate, cols, i + 1, cnt - 1);
            cols[j] = 0;
        }
    sum += dfs(plate, cols, i + 1, cnt);
    return sum;
}

int main()
{
    while (cin >> N >> K)
    {
        if (N == -1 && K == -1)
            break;
        vector<int> cols(N, 0);
        vector<vector<char> > plate(N, vector<char>(N));
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                cin >> plate[i][j];
        cout << dfs(plate, cols, 0, K) << endl;
    }
    return 0;
}